namespace GameConfig {
	/**游戏名称 */
	export let gameName: string = "JumpFloor";
	export let appid = "wx8c4c756c771c794c";
	export let isFirstLaunch:boolean = true;
	/**是否是发布版本 */
	export let isRelease: boolean = true;
	/**请求头cookie */
	export let requestHead: string = "";
	/**舞台宽 */
	export let stageWidth: number;
	/**舞台高 */
	export let stageHeight: number;
	/**小游戏版本号，请求服务器接口用 */
	export let isOnline: boolean = true;
	/**用于区分线上提审的不同版本，便于在审核期一些东西 */
	export let version: number = 7;
	export let versionStr: string = "1.0.6";
	/**接口前缀 */
	export let requestUrl: string = "";

	export let isGameOnShowing:boolean = false;
	
	/**舞台宽度与实际宽度的缩放比*/
	export let scale:number;
	export let systemInfo:any;
	
	/**第一个墙体起始x */
	export let floorHeight:number = 105;
	// export let floorHeight:number = 150;
	export let floorBorder:number = 15;
	export let floorMargin:number = 23;
	
	/**相册权限设置状态 */
	export let storageType: number = 0;
	/**sdk版本号 */
	export let SDKVersion: string;
	/**是否展示排行榜,是通过版本号来控制的低于"1.9.92" */
	export let showRank: boolean = false;
	/**2.0.0开始优化子域排行榜的显示 */
	export let showGameScenceRank:boolean = false;
	/**启动时从路径里获取到的微信打开小游戏时携带的参数data.shareTicket */
	export let shareTicket: string = null;
	/**game.js里的逻辑设置的内容data为onShow的参数,data.query.showRank == "true",暂时没有使用*/
	export let showGroupRank: boolean = false;
	export let query:any = null;
	/**启动时从query中获取到的id */
	export let shareId: string = null;
	export let launchData: any = null;

	export let worker:any;
	export let workerRequestIndex=-1;
	export let workerResponseIndex=-1;

	export let bannerAd:any;
	export let videoAd:any;

	export let adList:Array<any> = [];
	export let currentAd:any;
	export let currentAdIndex:number=0;
	/**加载广告列表 */
	export function requestAdList(callback?:Function){
		if(GameConfig.adList.length > 0){
			if(callback){
				callback();
			}
			return;
		}
		App.HttpRequestManager.request(NetConstants.AD_LIST, {}, (res)=>{
			if(res.statusCode == 200 && res.data.code == 0){
			let data = res.data.data as Array<any>;
			// 过滤当前的appid
			let adList = [];
			for(let i=0;i<data.length;i++){
				let ad = data[i];
				if(GameConfig.appid != ad.appid){
					adList.push(ad);
				}
			}
			GameConfig.adList = adList;
			if(callback){
				callback();
			}
		}
		}, egret.HttpMethod.GET);
	}
	/**改变当前的广告 */
	export function changeCurrentAd(callback?:Function){
		if(GameConfig.adList && GameConfig.adList.length>0){
			GameConfig.currentAdIndex = GameConfig.currentAdIndex+1;
			if(GameConfig.currentAdIndex>=GameConfig.adList.length){
				GameConfig.currentAdIndex = 0;
			}
			GameConfig.currentAd = GameConfig.adList[GameConfig.currentAdIndex];
			if(callback){
				callback();
			}
		}
	}
	export function createBannerAd(){
		// 没有时创建
		let width = 600/GameConfig.stageWidth*GameConfig.systemInfo.screenWidth;
		let height = 181/600*width;
		let top = GameConfig.systemInfo.screenHeight-height-9/GameConfig.stageHeight*GameConfig.systemInfo.screenHeight;
		let left = (GameConfig.systemInfo.screenWidth-width)/2;
		GameConfig.bannerAd = wx.createBannerAd({
			adUnitId: 'adunit-931cba52d661e030',
			style: {left: left,top: top, width:width,height:height}
		});
	}
	export function showBannerAd() {
		if(!StringUtil.sdkVersionCompare(GameConfig.SDKVersion,"2.0.4")){
			return;
		}
		if(!GameConfig.bannerAd){
			GameConfig.createBannerAd();
		}
		// 有时重新调整位置
		GameConfig.bannerAd.show();
		
	}
	export function hideBannerAd(){
		if(!StringUtil.sdkVersionCompare(GameConfig.SDKVersion,"2.0.4")){
			return;
		}
		if(GameConfig.bannerAd){
			GameConfig.bannerAd.destory();
			GameConfig.bannerAd = null;
		}
		GameConfig.createBannerAd();
	}
	
	/**uiIndex */
	export let uiIndex = {
		load: 0,
		home: 1, //首页
		game: 2,
		dieShare: 3,
		over: 4,
		opensetting: 5,
		moreGame: 6,
		rankListFromHome: 7,
		rankListFromOver: 8,
		mainReborn: 9,
		SkinShop: 10,
		diamondShop: 11, //钻石商城
		shopConfirm: 12,
		inviteReward: 13,
		groupRankList: 14,
		gameReborn: 15,
		pause:16,
		recommend:17,
		redpacket:18,
		clean: -1
	}
	/**向共享数据域发送的命令 */
	export let shareCavansCommand = {
		/**获取朋友关系链数据 */
		GET_FRIEND_INFO:"friend",
		/**check */
		CHECK_RANK:"check",
		/**展示某个页面对应的排行榜数据 */
		SHOW_RANK:"show_rank",
		/**清空共享数据域的排行榜数据及展示内容 */
		CLEAN_RANK:'clean',
		/**告诉排行榜当前主域展示的页面 */
		UPDATE_INDEX:"update_index",
		/**上一页的数据 */
		PRE_PAGE_RANK:"PRE_PAGE_RANK",
		/**下一页的数据 */
		NEXT_PAGE_RANK:"NEXT_PAGE_RANK"
	}
	export let isFloorTypeRateListInit:boolean = false;
	export let floorTypeRateList = [
		{
			min:1,
			max:10,
			rateList:[
				{
				 datas:[true,true],
				 rate:1.0
				},
				{
				 datas:[true,false],
				 rate:0.0
				},
				{
				 datas:[false,true],
				 rate:0.0
				},
				{
				 datas:[false,false],
				 rate:0.0
				},
			]
		},
		{
			min:11,
			max:50,
			rateList:[
				{
				 datas:[true,true],
				 rate:0.4
				},
				{
				 datas:[true,false],
				 rate:0.3
				},
				{
				 datas:[false,true],
				 rate:0.3
				},
				{
				 datas:[false,false],
				 rate:0.0
				},
			]
		},
		{
			min:51,
			max:100,
			rateList:[
				{
				 datas:[true,true],
				 rate:0.3
				},
				{
				 datas:[true,false],
				 rate:0.3
				},
				{
				 datas:[false,true],
				 rate:0.3
				},
				{
				 datas:[false,false],
				 rate:0.1
				},
			]
		},
		{
			min:101,
			max:500,
			rateList:[
				{
				 datas:[true,true],
				 rate:0.2
				},
				{
				 datas:[true,false],
				 rate:0.3
				},
				{
				 datas:[false,true],
				 rate:0.3
				},
				{
				 datas:[false,false],
				 rate:0.2
				},
			]
		},
		{
			min:501,
			max:1000,
			rateList:[
				{
				 datas:[true,true],
				 rate:0.2
				},
				{
				 datas:[true,false],
				 rate:0.25
				},
				{
				 datas:[false,true],
				 rate:0.25
				},
				{
				 datas:[false,false],
				 rate:0.3
				},
			]
		},
		{
			min:1001,
			max:10000000,
			rateList:[
				{
				 datas:[true,true],
				 rate:0.1
				},
				{
				 datas:[true,false],
				 rate:0.25
				},
				{
				 datas:[false,true],
				 rate:0.25
				},
				{
				 datas:[false,false],
				 rate:0.4
				},
			]
		},
	];
	
	/**背景墙砖块的内容 */
	export let stepImage = {
		width : 77,
		height : 71,
		hOffsetX : 45, //32
		hOffsetY : 12, //12
		vOffsetX : 0,
		vOffsetY : 43, //28;
		lastOffsetWidth:32
	}
	/**移动的球的信息 */
	export let ball = {
		width:41,
		height:41
	}
	
	// export let ballSpeed = {
	// 	speed1:{hSpeed:10,upVelocity:14},
	// 	speed2:{hSpeed:10,upVelocity:14},
	// 	speed3:{hSpeed:10,upVelocity:14},
	// 	speed4:{hSpeed:10,upVelocity:14},
	// 	speed5:{hSpeed:10,upVelocity:14},
	// }
	//全局字体颜色表--可以扩展
	export let TextColors = {
		white: 0xFFFFFF,//白色
		milkWhite: 0xfbf1af,//乳白色 
		grayWhite: 0xceb6a2,//灰白色
		yellow: 0xffff00,//金黄色 
		lightYellow: 0xffd375,//淡黄色
		orangeYellow: 0xff9900,//橘黄色//道具名称 //玩家姓名
		red: 0xf11300,//红色
		green: 0x00e500,//绿色 
		blue: 0x1a94d7,//蓝色 
		grayBlue: 0x2f5177,//墨蓝色 
		purple: 0xe938f2,//紫色 
		pink: 0xFF3030,//粉色 
		black: 0x2e2d2d,//黑色
		golden: 0xFFD700 //金色
	}
	// export let setpBgColors = [
	// 	[0x51d2d8,0x3bb2ce],
	// 	[0x77c2d2,0x3ea8ce],
	// 	[0xffd64a,0xff9f0a],	
	// ];
	export let setpBgColors = [
		[0x51d2d8,0x3bb2ce],
		[0x77c2d2,0x3ea8ce],
		[0xffd64a,0xff9f0a],
	];
	// 音效名称
	export let music = {
		bg: "BGM_mp3", // 背景音效
		dead: "Fall_mp3", //掉落
		jumpUp: "Jump_mp3", // 跳起
		rocket: "Rocket_mp3",//降落
		countDown:"countDown_mp3" // 倒计时
	}
	// 分享内容 策略A
	export let shareInfoA = [
		{ "title": "一口气上100楼，不费劲儿！", "imageUrl": "resource/assets/share/share1.jpg" },
  		{ "title": "一口气上100楼是一种怎样的体验？", "imageUrl": "resource/assets/share/share1.jpg" },
  		{ "title": "自从玩了这个游戏，每次上厕所都要一个小时！", "imageUrl": "resource/assets/share/share1.jpg" },
		{ "title": "独上高楼，望尽天涯路！", "imageUrl": "resource/assets/share/share1.jpg" },
		{ "title": "最好玩的跳跃游戏，不来了解下吗？", "imageUrl": "resource/assets/share/share1.jpg" }
	];
	// 分享内容 策略B
	export let shareInfoB1 = [
		{ "title": "厉害了，我上到了{number}楼，求超越！", "imageUrl": "resource/assets/share/share2.jpg" }
	];
	// 分享内容 策略B
	export let shareInfoB2 = [
		{ "title": "同样是上楼，为什么我这么优秀？", "imageUrl": "resource/assets/share/share2.jpg" }
	];
	// 分享内容 策略C
	export let shareInfoC = [
		{ "title": "我只想问，群里还有谁能一战的？", "imageUrl": "resource/assets/share/share3.jpg" },
		{ "title": "本群玩这个最厉害的竟然是她？！速速点击围观", "imageUrl": "resource/assets/share/share3.jpg" },
		{ "title": "来吧！看看谁能上1000层楼！", "imageUrl": "resource/assets/share/share3.jpg" }
	];
	
	// 分享的场景
	export let shareFrom = {
		other2Share:-2, // 未特别指明的地方分享的
		topRightMore:-1,// 右上角点击微信的。。。->转发
		invitePageWatchVideo2Share:0, // 邀请页看视频
		invitePageGiveFriend2Share:1, // 邀请页给好友送钻石
		invitePageReqFriend2Share:2, // 邀请页给好友送钻石
		homePage2Share:3,// 首页点击分享
		homePageGroup2Share:4,// 首页点击分享
		overPageChallenge2Share:5, // gameOver发起挑战
		rankListPageSeeGroup2Share:6, // 排行榜查看群排行
		skinShopPage2Share:7,
		recommend2Share:8
	}
	// 调用微信的分享
	/**
	 * 获取分享的数据
	 * shareInfo:策略
	 * score:用于替换{number}的参数
	 * query：额外参数
	 */
	export function getShareData(shareInfo:Array<any> = GameConfig.shareInfoA,query:any = null,score:number=0){
		
		let len = shareInfo.length;
		let index = Math.floor(Math.random()*len);
		let shareData = shareInfo[index];
		if(shareData && shareData.title && shareData.title.indexOf("{number}") != -1){
			shareData.title = shareData.title.replace("{number}",score)
		}
		if(!query){
			query = {};
		}
		if(typeof query == "string"){
			shareData.query = query;
		}else if(typeof query == "object"){
			// 添加默认参数
			if(query.showRank == undefined || query.showRank == "undefined"){
				query.showRank = true;
			}
			if(query.id == undefined || query.id == "undefined"){
				query.id = UserData.id;
			}
			if(query.from == undefined || query.from == "undefined"){
				query.from = GameConfig.shareFrom.other2Share;
			}
			// 将参数变成字符串
			let queryTxt = "";
			for(let key in query){
				if(queryTxt != ""){
					queryTxt = queryTxt+"&";
				}
				queryTxt = queryTxt+key+"="+query[key];
			}
			shareData.query = queryTxt;
		}
		return shareData;
	}

	// 缓存数据梯步数组
	export let globalFloors:Array<GameFloor> = [];
	// 获取缓存梯步
	export function getFoor(lastFloor:GameFloor):GameFloor{
		let floor:GameFloor;
		if(GameConfig.globalFloors.length){
			floor = GameConfig.globalFloors.pop();
			let hardLevel = GameHardLevel.createHardLevelByFloor(lastFloor);
			floor.hardLevel = hardLevel;
			floor.updateViews();
		}else{
			let hardLevel = GameHardLevel.createHardLevelByFloor(lastFloor);
			floor = new GameFloor(hardLevel);
		}
		return floor;
	}
	// 保存梯步数组
	export function saveFloor(floor:GameFloor):void{
		if(floor){
			if(floor.parent){
				floor.parent.removeChild(floor);
			}
			floor.resetData();
			GameConfig.globalFloors.push(floor);
		}
	}
	// 缓存数据竖直的墙数组
	export let globalVWallImgs:Array<eui.Image> = [];
	// 获取缓存竖直的墙
	export function getVerWall():eui.Image{
		let verWallImg:eui.Image;
		if(GameConfig.globalVWallImgs.length){
			verWallImg = GameConfig.globalVWallImgs.pop();
		}else{
			verWallImg = new eui.Image();
			verWallImg.source = "wallV_png";
		}
		return verWallImg;
	}
	// 保存竖直的墙数组
	export function saveVerWall(verWall:eui.Image):void{
		if(verWall){
			if(verWall.parent){
				verWall.parent.removeChild(verWall);
			}
			GameConfig.globalVWallImgs.push(verWall);
		}
	}
	// 缓存数据水平的墙数组
	export let globalHWallImgs:Array<eui.Image> = [];
	// 获取缓存竖直的墙
	export function getHorWall():eui.Image{
		let horWallImg:eui.Image;
		if(GameConfig.globalHWallImgs.length){
			horWallImg = GameConfig.globalHWallImgs.pop();
		}else{
			horWallImg = new eui.Image();
			horWallImg.source = "wallH_png";
		}
		return horWallImg;
	}
	// 保存竖直的墙数组
	export function saveHorWall(horWall:eui.Image):void{
		if(horWall){
			if(horWall.parent){
				horWall.parent.removeChild(horWall);
			}
			GameConfig.globalHWallImgs.push(horWall);
		}
	}
	// 缓存10的整数倍的的背景图数组
	export let globalBgImgs:Array<eui.Image> = [];
	// 获取缓存竖直的墙
	export function getBgImg(floorIndex:number):eui.Image{
		let bgImg:eui.Image;
		if(GameConfig.globalBgImgs.length){
			bgImg = GameConfig.globalBgImgs.pop();
		}else{
			bgImg = new eui.Image();
			// bgImg.source = "bgRow"+UserData.current_bgId+"_jpg";
		}
		let rowIndex = (Math.floor((floorIndex+1)/100)%2+1);
		if(rowIndex<1){
			rowIndex = 1;
		}else if(rowIndex>3){
			rowIndex = 3;
		}
		bgImg.source = "bgRow"+rowIndex+"_jpg";
		return bgImg;
	}
	// 保存竖直的墙数组
	export function saveBgImg(bgImg:eui.Image):void{
		if(bgImg){
			if(bgImg.parent){
				bgImg.parent.removeChild(bgImg);
			}
			GameConfig.globalBgImgs.push(bgImg);
		}
	}
	
	
}